<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            position: relative;
            background-color: chocolate;
        }

        .btn {
            position: absolute;
            font-size: 12px;
            color: white;
            background: transparent;
            border: 0;
            right: 0px;
            top: 0;
        }
    </style>
</head>

<body>

    <div class="box">一刀999!来传奇
        !<br>和子丹一起疯狂砍人
        <button class="btn">关闭广告</button></div>
    <script>
        var boxEle = document.querySelector("div")
        // console.log(boxEle);
        var btnn = document.querySelector(".btn")
        var flag = true;
        btnn.onclick = function () {
            if (flag) {
                boxEle.style.display = "none"
            }
        }
        setInterval(function () {
            boxEle.style.display = "block"
        }, 4000)
    </script>
</body>

</html>